package com.elawlink.controller;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.elawlink.common.ReturnBean;
import com.elawlink.util.FileUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;


@RestController
@RequestMapping("/")
@Api(value = "首页接口", tags = "首页接口")
public class IndexController {

	/**
	 * 获取指定目录下面文件列表
	 * @return
	 */
	@ApiOperation(value = "获取指定目录下面文件列表", notes = "获取指定目录下面文件列表")
	@RequestMapping(value = "/getFileList", produces = MediaType.APPLICATION_JSON_UTF8_VALUE, method = {RequestMethod.GET,RequestMethod.POST})
	public ResponseEntity<ReturnBean> getFileList(HttpServletRequest request, HttpServletResponse response,
		    @ApiParam(value = "path") @RequestParam(value = "path", required = true) String path){
		
		System.out.println("获取指定目录下面文件列表：path="+path);
		
		List<String> list = new ArrayList<String>();
		list = FileUtil.getFileListNotEmpty(list, path);
		
		return new ResponseEntity<ReturnBean>(new ReturnBean(list), HttpStatus.OK);
	}
	
	
	
}







